package com.sky.business.sys.event.endpoint;

import com.sky.business.sys.domain.CameraConfig;
import com.sky.business.sys.domain.SystemConfig;
import lombok.Data;

/**
 * 设备信息
 */
@Data
public class DeviceInfoDto {
    private String cameraIp;
    private String cameraPort;
    private String cameraRtspPort;
    private String onvifUser;
    private String onvifPasswd;
    private String cameraLongitude;
    private String cameraLatitude;
    private String cameraAltitude;
    private String panAngleTrim;
    private String tiltAngleTrim;
    private String cameraFocalLenMin;
    private String cameraZoomRangeMax;
    private String cameraTiltRangeMin;
    private String cameraTiltRangeMax;
    private String originalPushStream;
    private String aiPushStream;
    private String pullStream;
    private String aiPullStream;
    private String minZoomRatio;
    private String maxZoomRatio;
    private Boolean autoZoom;
    private String pixelSize;
    private String objWidth;
    private String objHeight;
    private String minZoomDistance;
    private String horizontalMoveThreshold;
    private String verticalMoveThreshold;
    private String deviceType;
    private String ratio;
    private Integer reverse;
    private Integer controlMode;
    private Integer ptdPort;

    /**
     * 把设备信息转换为dto
     * @param camera 设备信息
     * @param systemConfig 系统配置
     * @return dto
     */
    public static DeviceInfoDto valueOf(CameraConfig camera, SystemConfig systemConfig){
        DeviceInfoDto deviceInfoDto = new DeviceInfoDto();
        deviceInfoDto.cameraIp = camera.getCameraIp();
        deviceInfoDto.cameraPort = camera.getCameraPort();
        deviceInfoDto.cameraRtspPort = camera.getCameraRtspPort();
        deviceInfoDto.onvifUser = camera.getOnvifUser();
        deviceInfoDto.onvifPasswd = camera.getOnvifPasswd();
        deviceInfoDto.cameraLongitude = camera.getCameraLongitude();
        deviceInfoDto.cameraLatitude = camera.getCameraLatitude();
        deviceInfoDto.cameraAltitude = camera.getCameraAltitude();
        deviceInfoDto.panAngleTrim = camera.getPanAngle();
        deviceInfoDto.tiltAngleTrim = camera.getTiltAngle();
        deviceInfoDto.cameraFocalLenMin = camera.getCameraFocalLenMin();
        deviceInfoDto.cameraZoomRangeMax = camera.getCameraZoomRangeMax();
        deviceInfoDto.cameraTiltRangeMin = camera.getCameraTiltRangeMin();
        deviceInfoDto.cameraTiltRangeMax = camera.getCameraTiltRangeMax();
        deviceInfoDto.originalPushStream = camera.getPushStream();
        deviceInfoDto.aiPushStream = camera.getAiPushStream();
        deviceInfoDto.pullStream = camera.getPullStream();
        deviceInfoDto.aiPullStream = camera.getAiPullStream();
        deviceInfoDto.minZoomRatio = systemConfig.getMinZoomRatio();
        deviceInfoDto.maxZoomRatio = systemConfig.getMaxZoomRatio();
        deviceInfoDto.autoZoom = camera.getAutoZoom();
        deviceInfoDto.pixelSize = camera.getPixelSize();
        deviceInfoDto.objHeight = systemConfig.getObjHeight();
        deviceInfoDto.objWidth = systemConfig.getObjWidth();
        deviceInfoDto.minZoomDistance = systemConfig.getMinZoomDistance();
        deviceInfoDto.horizontalMoveThreshold = systemConfig.getHorizontalMoveThreshold();
        deviceInfoDto.verticalMoveThreshold = systemConfig.getVerticalMoveThreshold();
        deviceInfoDto.deviceType = camera.getDeviceType();
        deviceInfoDto.ratio = systemConfig.getRatio();
        deviceInfoDto.reverse = camera.getReverse() ?-1:1;
        deviceInfoDto.controlMode = camera.getControlMode().getValue();
        deviceInfoDto.ptdPort = camera.getPtdPort()!=null?camera.getPtdPort():8089;
        return deviceInfoDto;
    }
}
